package djrain.testListRound;

import java.util.zip.Inflater;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class testListRound extends Activity {
	private LayoutInflater infilter;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		infilter = getLayoutInflater();

		ListView lv = (ListView) findViewById(R.id.ListView01);
		lv.setAdapter(new MyAdapter());

	}

	public class MyAdapter extends BaseAdapter implements ListAdapter {
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return 1;
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {

			if (convertView == null) {
				convertView = infilter.inflate(R.layout.listitem, null);
			}

			TextView tvTop = (TextView) convertView.findViewById(R.id.top);
			TextView tvBottom = (TextView) convertView.findViewById(R.id.bottom);

			if (position == 0) {
				tvTop.getBackground().setLevel(1);
			}else{
				tvTop.getBackground().setLevel(0);
			}

			if (position == getCount() - 1) {
				tvBottom.getBackground().setLevel(1);
			}else{
				tvBottom.getBackground().setLevel(0);
			}
			return convertView;
		}
	}
}